package com.ohuang.test_compose.size

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.TextUnit

import androidx.compose.ui.unit.sp

val LocalComposeSize = compositionLocalOf {
    1f
}

@Stable

inline val Int.dpLocal: Dp
    @Composable
    get() = Dp(value = this.toFloat() * LocalComposeSize.current)


@Stable
inline val Double.dpLocal: Dp
    @Composable
    get() = Dp(value = this.toFloat() * LocalComposeSize.current)

@Stable
inline val Float.dpLocal: Dp
    @Composable
    get() = Dp(value = this * LocalComposeSize.current)


@Stable

val Int.spLocal: TextUnit
    @Composable
    get() = (this.toFloat()* LocalComposeSize.current).sp

@Stable

val Double.spLocal: TextUnit
    @Composable
    get() = (this* LocalComposeSize.current).sp

@Stable

val Float.spLocal: TextUnit
    @Composable
    get() = (this* LocalComposeSize.current).sp

